package com.codeOfDoom.Sets.Managers.SetsManager
{
	import com.codeOfDoom.Sets.SetsCard.ICard;
	import com.codeOfDoom.Sets.SetsCard.SetsCard;
	
	import mx.collections.ArrayCollection;

	public  class SetsManager implements ISetsManager
	{
		public static const propertiesToCheck:Array = ["color","shape","shading","number"];

		public static function verify(setCollection:ArrayCollection):Boolean{
			var isProperSet:Boolean = false;
		    for each (var prop:String in propertiesToCheck){
		    	isProperSet=false;
			    if (((setCollection.getItemAt(0) as SetsCard).byName(prop) == (setCollection.getItemAt(1) as SetsCard).byName(prop)) && ((setCollection.getItemAt(1) as SetsCard).byName(prop) == (setCollection.getItemAt(2) as SetsCard).byName(prop))){
			    	isProperSet = true;        
			    }
		      	if (!isProperSet){
		        	if (((setCollection.getItemAt(0) as SetsCard).byName(prop) != (setCollection.getItemAt(1) as SetsCard).byName(prop)) && ((setCollection.getItemAt(1) as SetsCard).byName(prop) != (setCollection.getItemAt(2) as SetsCard).byName(prop)) && ((setCollection.getItemAt(0) as SetsCard).byName(prop) != (setCollection.getItemAt(2) as SetsCard).byName(prop))){
	          			isProperSet = true;
		         	}
		        }
		        if (isProperSet==false)
		        	return false;
		      }    
		    return isProperSet;
		}
		
	}
}